﻿namespace QLPhongKham.UC
{
    using DevExpress.Data;
    using DevExpress.Utils;
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using DevExpress.XtraEditors.Repository;
    using DevExpress.XtraGrid;
    using DevExpress.XtraGrid.Columns;
    using DevExpress.XtraGrid.Views.Base;
    using DevExpress.XtraGrid.Views.Grid;
    using DevExpress.XtraTab;
    using QLPhongKham.Access;
    using QLPhongKham.Access.BenhNhan;
    using QLPhongKham.BaseClass.BenhNhan;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;

    public class ucbn_thongtinbn : XtraUserControl
    {
        private General _xuli;
        private SimpleButton btnxoa;
        private LookUpEdit cbbgioitinh;
        private IContainer components;
        private GridControl gridds;
        private GridColumn gridds_diachi;
        private GridColumn gridds_dienthoai;
        private GridColumn gridds_idgioitinh;
        private GridColumn gridds_idphuongxa;
        private GridColumn gridds_mabn;
        private GridColumn gridds_namsinh;
        private GridColumn gridds_ngaysinh;
        private GridColumn gridds_phai;
        private GridColumn gridds_phuongxa;
        private GridColumn gridds_ten;
        private GridView gridView1;
        private GroupControl groupControl1;
        private Label label1;
        private Label label2;
        private Label label3;
        private Label label30;
        private Label label4;
        private Label label5;
        private Label label6;
        private Label label7;
        private Label label8;
        public bool pLayThongTinBN;
        public string pMaBNChon;
        private RepositoryItemTextEdit repositoryItemTextEdit1;
        private SimpleButton sbtnboqua;
        private SimpleButton sbtnketthuc;
        private SimpleButton sbtnluu;
        private SimpleButton sbtnsua;
        private TextEdit txtdiachi;
        private TextEdit txtdienthoai;
        private TextEdit txthoten;
        private TextEdit txtmabn2;
        private TextEdit txtmaphuongxa;
        private TextEdit txtnamsinh;
        private MaskedTextBox txtngaysinh;
        private TextEdit txttenphuongxa;

        public ucbn_thongtinbn()
        {
            this.pLayThongTinBN = false;
            this.pMaBNChon = "";
            this.components = null;
            this.InitializeComponent();
            this._xuli = new General();
        }

        public ucbn_thongtinbn(General xuli)
        {
            this.pLayThongTinBN = false;
            this.pMaBNChon = "";
            this.components = null;
            this.InitializeComponent();
            this._xuli = xuli;
        }

        private void btnxoa_Click(object sender, EventArgs e)
        {
            if (((this.txtmabn2.Text != "") && !(this.txthoten.Text == "")) && (MessageBox.Show("Bạn c\x00f3 chắc chắn muốn hủy th\x00f4ng tin bệnh nh\x00e2n n\x00e0y kh\x00f4ng?", "Th\x00f4ng b\x00e1o", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes))
            {
                if (new BNTiepDon(this._xuli.pConFigData).f_loaddata_caclandk(this.txtmabn2.Text).Rows.Count > 0)
                {
                    MessageBox.Show("Hủy th\x00f4ng tin kh\x00f4ng th\x00e0nh c\x00f4ng.\nBệnh nh\x00e2n đ\x00e3 ph\x00e1t sinh hồ sơ bệnh \x00e1n.", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    dtoBNThongTinBN nbn = new dtoBNThongTinBN(this._xuli.pConFigData) {
                        MABN = this.txtmabn2.Text
                    };
                    nbn.Load();
                    if (!nbn.Delete())
                    {
                        MessageBox.Show("Hủy th\x00f4ng tin kh\x00f4ng th\x00e0nh c\x00f4ng.\nVui l\x00f2ng kiểm tra lại.", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else
                    {
                        this.f_loaddata_dsbenhnhan();
                        this.f_loadinfo_dmsanpham(0);
                    }
                }
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private bool f_kiemtra_luu()
        {
            if (this.txtmabn2.Text == "")
            {
                MessageBox.Show("Chưa nhập m\x00e3 bệnh nh\x00e2n.", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                this.txthoten.Focus();
                return false;
            }
            if (this.txthoten.Text == "")
            {
                MessageBox.Show("Chưa nhập họ v\x00e0 t\x00ean của bệnh nh\x00e2n.", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                this.txthoten.Focus();
                return false;
            }
            try
            {
                int num = Convert.ToInt16(this.txtnamsinh.Text);
            }
            catch
            {
                MessageBox.Show("Chưa nhập năm sinh của bệnh nh\x00e2n.", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                this.txtnamsinh.Focus();
                return false;
            }
            return true;
        }

        private void f_loadcontrol_benhnhan(string mabn, string hoten, int gioitinh, string ngaysinh, string namsinh, string diachi, string dienthoai, long idphuongxa)
        {
            try
            {
                this.txtmabn2.Text = mabn;
            }
            catch
            {
            }
            this.txthoten.Text = hoten;
            this.cbbgioitinh.EditValue = gioitinh;
            this.txtngaysinh.Text = ngaysinh;
            this.txtnamsinh.Text = namsinh.ToString();
            this.txtnamsinh_Validated(null, null);
            this.txtdiachi.Text = diachi;
            this.txtdienthoai.Text = dienthoai;
            this.f_setcontrol_phuongxa("", idphuongxa);
        }

        private void f_loadcontrol_chophepsua(bool chophep)
        {
            this.sbtnketthuc.Enabled = this.sbtnsua.Enabled = this.btnxoa.Enabled = !chophep;
            this.sbtnluu.Enabled = this.sbtnboqua.Enabled = chophep;
        }

        private void f_loaddata_dsbenhnhan()
        {
            try
            {
                this.gridds.DataSource = new BNDanhMuc(this._xuli.pConFigData).f_load_bn_dsbenhnhan();
            }
            catch
            {
            }
        }

        private void f_loadinfo_dmsanpham(int indexrow)
        {
            try
            {
                this.f_loadcontrol_benhnhan(this.gridView1.GetRowCellValue(indexrow, this.gridds_mabn).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_ten).ToString(), int.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_idgioitinh).ToString()), this.gridView1.GetRowCellValue(indexrow, this.gridds_ngaysinh).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_namsinh).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_diachi).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_dienthoai).ToString(), long.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_idphuongxa).ToString()));
            }
            catch
            {
            }
        }

        private void f_SetControl_benhnhan(string mabn)
        {
            try
            {
                dtoBNThongTinBN nbn = new dtoBNThongTinBN(this._xuli.pConFigData) {
                    MABN = mabn
                };
                nbn.Load();
                this.f_loadcontrol_benhnhan(nbn.MABN, nbn.HOTEN, nbn.IDGIOITINH, nbn.NGAYSINH, nbn.NAMSINH.ToString(), nbn.DIACHI, nbn.DIENTHOAI, nbn.IDPHUONGXA);
            }
            catch
            {
                this.f_loadcontrol_benhnhan("", "", 0, "", "", "", "", 0L);
            }
        }

        private void f_setcontrol_phuongxa(string maphuongxa, long idphuongxa)
        {
            try
            {
                DataTable table = new BNDanhMuc(this._xuli.pConFigData).f_loaddata_tinhphuongxa(maphuongxa, idphuongxa);
                this.txttenphuongxa.Text = table.Rows[0]["ten"].ToString();
                this.txttenphuongxa.Tag = table.Rows[0]["idtinhthanh"].ToString() + "^" + table.Rows[0]["idquanhuyen"].ToString() + "^" + table.Rows[0]["idphuongxa"].ToString();
                this.txtmaphuongxa.Tag = table.Rows[0]["id"].ToString();
                this.txtmaphuongxa.Text = table.Rows[0]["viettat"].ToString();
            }
            catch
            {
                this.txttenphuongxa.Text = "";
                this.txtmaphuongxa.Tag = 0;
                this.txtmaphuongxa.Text = "";
            }
        }

        private void f_tinh_tuoi()
        {
            try
            {
                DateTime now = DateTime.Now;
                if (this.txtngaysinh.Text != "")
                {
                    try
                    {
                        now = new BNTiepDon(this._xuli.pConFigData).f_tinh_ngaytuoi(this.txtngaysinh.Text, 0, 0, 0);
                    }
                    catch
                    {
                    }
                }
                if (this.txtnamsinh.Text == "")
                {
                    this.txtnamsinh.Text = now.Year.ToString();
                }
            }
            catch
            {
            }
        }

        private void gridds_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                this.gridView1_FocusedRowChanged(null, null);
                this.pMaBNChon = this.txtmabn2.Text;
                if (this.pLayThongTinBN)
                {
                    this.stbnketthuc_Click(null, null);
                }
            }
            catch
            {
            }
        }

        private void gridView1_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e)
        {
            int indexrow = 0;
            try
            {
                if (this.gridView1.IsFocusedView)
                {
                    indexrow = this.gridView1.GetSelectedRows()[0];
                    this.f_loadinfo_dmsanpham(indexrow);
                }
            }
            catch
            {
            }
        }

        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(ucbn_thongtinbn));
            this.label1 = new Label();
            this.label2 = new Label();
            this.txthoten = new TextEdit();
            this.label3 = new Label();
            this.txtdiachi = new TextEdit();
            this.label4 = new Label();
            this.sbtnluu = new SimpleButton();
            this.sbtnboqua = new SimpleButton();
            this.sbtnketthuc = new SimpleButton();
            this.label5 = new Label();
            this.txtdienthoai = new TextEdit();
            this.label6 = new Label();
            this.label7 = new Label();
            this.txtnamsinh = new TextEdit();
            this.groupControl1 = new GroupControl();
            this.txtngaysinh = new MaskedTextBox();
            this.txtmaphuongxa = new TextEdit();
            this.txttenphuongxa = new TextEdit();
            this.label30 = new Label();
            this.cbbgioitinh = new LookUpEdit();
            this.txtmabn2 = new TextEdit();
            this.sbtnsua = new SimpleButton();
            this.btnxoa = new SimpleButton();
            this.label8 = new Label();
            this.gridds = new GridControl();
            this.gridView1 = new GridView();
            this.gridds_mabn = new GridColumn();
            this.gridds_ten = new GridColumn();
            this.repositoryItemTextEdit1 = new RepositoryItemTextEdit();
            this.gridds_idgioitinh = new GridColumn();
            this.gridds_phai = new GridColumn();
            this.gridds_namsinh = new GridColumn();
            this.gridds_diachi = new GridColumn();
            this.gridds_dienthoai = new GridColumn();
            this.gridds_phuongxa = new GridColumn();
            this.gridds_idphuongxa = new GridColumn();
            this.gridds_ngaysinh = new GridColumn();
            this.txthoten.Properties.BeginInit();
            this.txtdiachi.Properties.BeginInit();
            this.txtdienthoai.Properties.BeginInit();
            this.txtnamsinh.Properties.BeginInit();
            this.groupControl1.BeginInit();
            this.groupControl1.SuspendLayout();
            this.txtmaphuongxa.Properties.BeginInit();
            this.txttenphuongxa.Properties.BeginInit();
            this.cbbgioitinh.Properties.BeginInit();
            this.txtmabn2.Properties.BeginInit();
            this.gridds.BeginInit();
            this.gridView1.BeginInit();
            this.repositoryItemTextEdit1.BeginInit();
            base.SuspendLayout();
            this.label1.Font = new Font("Microsoft Sans Serif", 10f, FontStyle.Regular, GraphicsUnit.Point, 0);
            this.label1.Location = new Point(5, 0x1f);
            this.label1.Name = "label1";
            this.label1.Size = new Size(0x56, 0x17);
            this.label1.TabIndex = 0;
            this.label1.Text = "M\x00e3 BN:";
            this.label1.TextAlign = ContentAlignment.MiddleRight;
            this.label2.Font = new Font("Microsoft Sans Serif", 10f, FontStyle.Regular, GraphicsUnit.Point, 0);
            this.label2.Location = new Point(180, 0x1f);
            this.label2.Name = "label2";
            this.label2.Size = new Size(0x5b, 0x17);
            this.label2.TabIndex = 0;
            this.label2.Text = "Họ v\x00e0 t\x00ean:";
            this.label2.TextAlign = ContentAlignment.MiddleRight;
            this.txthoten.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.txthoten.Location = new Point(0x10c, 0x1f);
            this.txthoten.Name = "txthoten";
            this.txthoten.Properties.Appearance.Font = new Font("Microsoft Sans Serif", 10f, FontStyle.Regular, GraphicsUnit.Point, 0);
            this.txthoten.Properties.Appearance.Options.UseFont = true;
            this.txthoten.Properties.CharacterCasing = CharacterCasing.Upper;
            this.txthoten.Size = new Size(0xda, 0x16);
            this.txthoten.TabIndex = 1;
            this.txthoten.TextChanged += new EventHandler(this.txthoten_TextChanged);
            this.txthoten.Enter += new EventHandler(this.txthoten_Enter);
            this.txthoten.KeyDown += new KeyEventHandler(this.txthoten_KeyDown);
            this.label3.Font = new Font("Microsoft Sans Serif", 10f, FontStyle.Regular, GraphicsUnit.Point, 0);
            this.label3.Location = new Point(5, 0x3a);
            this.label3.Name = "label3";
            this.label3.Size = new Size(0x56, 0x18);
            this.label3.TabIndex = 0;
            this.label3.Text = "Địa chỉ:";
            this.label3.TextAlign = ContentAlignment.MiddleRight;
            this.txtdiachi.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.txtdiachi.Location = new Point(0x56, 0x3b);
            this.txtdiachi.Name = "txtdiachi";
            this.txtdiachi.Properties.Appearance.Font = new Font("Microsoft Sans Serif", 10f, FontStyle.Regular, GraphicsUnit.Point, 0);
            this.txtdiachi.Properties.Appearance.Options.UseFont = true;
            this.txtdiachi.Size = new Size(0x224, 0x16);
            this.txtdiachi.TabIndex = 8;
            this.txtdiachi.KeyDown += new KeyEventHandler(this.ucbn_tiepdon_KeyDown);
            this.label4.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.label4.Font = new Font("Microsoft Sans Serif", 10f, FontStyle.Regular, GraphicsUnit.Point, 0);
            this.label4.Location = new Point(0x1e3, 30);
            this.label4.Name = "label4";
            this.label4.Size = new Size(0x47, 0x18);
            this.label4.TabIndex = 0;
            this.label4.Text = "Giới t\x00ednh:";
            this.label4.TextAlign = ContentAlignment.MiddleRight;
            this.sbtnluu.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.sbtnluu.Appearance.Font = new Font("Tahoma", 10f);
            this.sbtnluu.Appearance.Options.UseFont = true;
            this.sbtnluu.Image = Properties.Resources.imgsave;// (Image)manager.GetObject("sbtnluu.Image");
            this.sbtnluu.Location = new Point(1, 0x1d9);
            this.sbtnluu.Name = "sbtnluu";
            this.sbtnluu.Size = new Size(80, 0x17);
            this.sbtnluu.TabIndex = 2;
            this.sbtnluu.Text = " &Lưu [F5]";
            this.sbtnluu.Click += new EventHandler(this.sbtnluu_Click);
            this.sbtnboqua.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.sbtnboqua.Appearance.Font = new Font("Tahoma", 10f);
            this.sbtnboqua.Appearance.Options.UseFont = true;
            this.sbtnboqua.Image = (Image) manager.GetObject("sbtnboqua.Image");
            this.sbtnboqua.Location = new Point(170, 0x1d9);
            this.sbtnboqua.Name = "sbtnboqua";
            this.sbtnboqua.Size = new Size(0x5c, 0x17);
            this.sbtnboqua.TabIndex = 5;
            this.sbtnboqua.Text = "&Bỏ qua [F4]";
            this.sbtnboqua.Click += new EventHandler(this.sbtnboqua_Click);
            this.sbtnketthuc.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.sbtnketthuc.Appearance.Font = new Font("Tahoma", 10f);
            this.sbtnketthuc.Appearance.Options.UseFont = true;
            this.sbtnketthuc.Image = (Image) manager.GetObject("sbtnketthuc.Image");
            this.sbtnketthuc.ImeMode = ImeMode.NoControl;
            this.sbtnketthuc.Location = new Point(0x31b, 0x1d9);
            this.sbtnketthuc.Name = "sbtnketthuc";
            this.sbtnketthuc.Size = new Size(130, 0x17);
            this.sbtnketthuc.TabIndex = 7;
            this.sbtnketthuc.Text = "&Kết th\x00fac [F12]";
            this.sbtnketthuc.Click += new EventHandler(this.stbnketthuc_Click);
            this.label5.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.label5.Font = new Font("Microsoft Sans Serif", 10f, FontStyle.Regular, GraphicsUnit.Point, 0);
            this.label5.Location = new Point(0x271, 0x3a);
            this.label5.Name = "label5";
            this.label5.Size = new Size(0x58, 0x19);
            this.label5.TabIndex = 0;
            this.label5.Text = "Điện thoại:";
            this.label5.TextAlign = ContentAlignment.MiddleRight;
            this.txtdienthoai.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.txtdienthoai.Location = new Point(710, 0x3b);
            this.txtdienthoai.Name = "txtdienthoai";
            this.txtdienthoai.Properties.Appearance.Font = new Font("Microsoft Sans Serif", 10f, FontStyle.Regular, GraphicsUnit.Point, 0);
            this.txtdienthoai.Properties.Appearance.Options.UseFont = true;
            this.txtdienthoai.Size = new Size(0xce, 0x16);
            this.txtdienthoai.TabIndex = 9;
            this.txtdienthoai.KeyDown += new KeyEventHandler(this.ucbn_tiepdon_KeyDown);
            this.label6.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.label6.Font = new Font("Microsoft Sans Serif", 10f, FontStyle.Regular, GraphicsUnit.Point, 0);
            this.label6.Location = new Point(0x271, 0x1f);
            this.label6.Name = "label6";
            this.label6.Size = new Size(0x5b, 0x16);
            this.label6.TabIndex = 6;
            this.label6.Text = "Ng\x00e0y sinh:";
            this.label6.TextAlign = ContentAlignment.MiddleRight;
            this.label7.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.label7.Font = new Font("Microsoft Sans Serif", 10f, FontStyle.Regular, GraphicsUnit.Point, 0);
            this.label7.Location = new Point(0x310, 0x1f);
            this.label7.Name = "label7";
            this.label7.Size = new Size(0x5b, 0x16);
            this.label7.TabIndex = 0;
            this.label7.Text = "Năm sinh:";
            this.label7.TextAlign = ContentAlignment.MiddleRight;
            this.txtnamsinh.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.txtnamsinh.Location = new Point(0x368, 0x1f);
            this.txtnamsinh.Name = "txtnamsinh";
            this.txtnamsinh.Properties.Appearance.Font = new Font("Microsoft Sans Serif", 10f, FontStyle.Regular, GraphicsUnit.Point, 0);
            this.txtnamsinh.Properties.Appearance.Options.UseFont = true;
            this.txtnamsinh.Properties.CharacterCasing = CharacterCasing.Upper;
            this.txtnamsinh.Properties.MaxLength = 4;
            this.txtnamsinh.Size = new Size(0x2c, 0x16);
            this.txtnamsinh.TabIndex = 5;
            this.txtnamsinh.KeyDown += new KeyEventHandler(this.ucbn_tiepdon_KeyDown);
            this.txtnamsinh.Validated += new EventHandler(this.txtnamsinh_Validated);
            this.groupControl1.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom;
            this.groupControl1.Appearance.Font = new Font("Tahoma", 10f);
            this.groupControl1.Appearance.Options.UseFont = true;
            this.groupControl1.AppearanceCaption.BackColor = Color.FromArgb(0xe3, 0xef, 0xff);
            this.groupControl1.AppearanceCaption.Font = new Font("Tahoma", 12f, FontStyle.Bold);
            this.groupControl1.AppearanceCaption.Options.UseBackColor = true;
            this.groupControl1.AppearanceCaption.Options.UseFont = true;
            this.groupControl1.Controls.Add(this.txtngaysinh);
            this.groupControl1.Controls.Add(this.txtmaphuongxa);
            this.groupControl1.Controls.Add(this.txttenphuongxa);
            this.groupControl1.Controls.Add(this.label30);
            this.groupControl1.Controls.Add(this.cbbgioitinh);
            this.groupControl1.Controls.Add(this.txthoten);
            this.groupControl1.Controls.Add(this.label4);
            this.groupControl1.Controls.Add(this.txtdienthoai);
            this.groupControl1.Controls.Add(this.txtmabn2);
            this.groupControl1.Controls.Add(this.txtdiachi);
            this.groupControl1.Controls.Add(this.txtnamsinh);
            this.groupControl1.Controls.Add(this.label3);
            this.groupControl1.Controls.Add(this.label2);
            this.groupControl1.Controls.Add(this.label5);
            this.groupControl1.Controls.Add(this.label7);
            this.groupControl1.Controls.Add(this.label1);
            this.groupControl1.Controls.Add(this.label6);
            this.groupControl1.Location = new Point(1, 0x15c);
            this.groupControl1.Name = "groupControl1";
            this.groupControl1.Size = new Size(0x39f, 0x77);
            this.groupControl1.TabIndex = 0;
            this.groupControl1.Text = "Th\x00f4ng tin h\x00e0nh ch\x00ednh";
            this.txtngaysinh.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.txtngaysinh.Font = new Font("Tahoma", 10f);
            this.txtngaysinh.Location = new Point(710, 0x1d);
            this.txtngaysinh.Mask = "00/00/0000";
            this.txtngaysinh.Name = "txtngaysinh";
            this.txtngaysinh.Size = new Size(0x52, 0x18);
            this.txtngaysinh.TabIndex = 4;
            this.txtngaysinh.ValidatingType = typeof(DateTime);
            this.txtngaysinh.KeyDown += new KeyEventHandler(this.ucbn_tiepdon_KeyDown);
            this.txtngaysinh.Validated += new EventHandler(this.txtngaysinh_Validated);
            this.txtmaphuongxa.Location = new Point(0x56, 0x59);
            this.txtmaphuongxa.Name = "txtmaphuongxa";
            this.txtmaphuongxa.Properties.Appearance.Font = new Font("Microsoft Sans Serif", 10f, FontStyle.Regular, GraphicsUnit.Point, 0);
            this.txtmaphuongxa.Properties.Appearance.Options.UseFont = true;
            this.txtmaphuongxa.Properties.CharacterCasing = CharacterCasing.Upper;
            this.txtmaphuongxa.Size = new Size(0x5f, 0x16);
            this.txtmaphuongxa.TabIndex = 10;
            this.txtmaphuongxa.ToolTipTitle = "M\x00e3 viết tắt";
            this.txtmaphuongxa.KeyDown += new KeyEventHandler(this.ucbn_tiepdon_KeyDown);
            this.txtmaphuongxa.Validated += new EventHandler(this.txtmaphuongxa_Validated);
            this.txttenphuongxa.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.txttenphuongxa.Location = new Point(0xb7, 0x59);
            this.txttenphuongxa.Name = "txttenphuongxa";
            this.txttenphuongxa.Properties.Appearance.Font = new Font("Microsoft Sans Serif", 10f, FontStyle.Regular, GraphicsUnit.Point, 0);
            this.txttenphuongxa.Properties.Appearance.Options.UseFont = true;
            this.txttenphuongxa.Size = new Size(0x2dd, 0x16);
            this.txttenphuongxa.TabIndex = 11;
            this.txttenphuongxa.KeyDown += new KeyEventHandler(this.ucbn_tiepdon_KeyDown);
            this.label30.Font = new Font("Microsoft Sans Serif", 10f, FontStyle.Regular, GraphicsUnit.Point, 0);
            this.label30.Location = new Point(0x20, 0x57);
            this.label30.Name = "label30";
            this.label30.Size = new Size(0x31, 0x16);
            this.label30.TabIndex = 0x17;
            this.label30.Text = "T/P/X:";
            this.label30.TextAlign = ContentAlignment.MiddleRight;
            this.cbbgioitinh.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.cbbgioitinh.Location = new Point(0x228, 0x20);
            this.cbbgioitinh.Name = "cbbgioitinh";
            this.cbbgioitinh.Properties.Appearance.Font = new Font("Tahoma", 10f);
            this.cbbgioitinh.Properties.Appearance.Options.UseFont = true;
            this.cbbgioitinh.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.cbbgioitinh.Properties.Columns.AddRange(new LookUpColumnInfo[] { new LookUpColumnInfo("id", "id", 20, FormatType.None, "", false, HorzAlignment.Default), new LookUpColumnInfo("ten", "Tuổi") });
            this.cbbgioitinh.Properties.NullText = "";
            this.cbbgioitinh.Size = new Size(0x52, 0x16);
            this.cbbgioitinh.TabIndex = 7;
            this.cbbgioitinh.EditValueChanged += new EventHandler(this.lkploaituoi_EditValueChanged);
            this.cbbgioitinh.KeyDown += new KeyEventHandler(this.ucbn_tiepdon_KeyDown);
            this.txtmabn2.Location = new Point(0x56, 0x1f);
            this.txtmabn2.Name = "txtmabn2";
            this.txtmabn2.Properties.Appearance.Font = new Font("Microsoft Sans Serif", 10f, FontStyle.Regular, GraphicsUnit.Point, 0);
            this.txtmabn2.Properties.Appearance.Options.UseFont = true;
            this.txtmabn2.Properties.MaxLength = 10;
            this.txtmabn2.Size = new Size(0x5f, 0x16);
            this.txtmabn2.TabIndex = 0;
            this.txtmabn2.KeyDown += new KeyEventHandler(this.ucbn_tiepdon_KeyDown);
            this.txtmabn2.Validated += new EventHandler(this.txtmabn2_Validated);
            this.sbtnsua.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.sbtnsua.Appearance.Font = new Font("Tahoma", 10f);
            this.sbtnsua.Appearance.Options.UseFont = true;
            this.sbtnsua.Image = (Image) manager.GetObject("sbtnsua.Image");
            this.sbtnsua.Location = new Point(0x54, 0x1d9);
            this.sbtnsua.Name = "sbtnsua";
            this.sbtnsua.Size = new Size(0x52, 0x17);
            this.sbtnsua.TabIndex = 4;
            this.sbtnsua.Text = "&Sửa [F3]";
            this.sbtnsua.Click += new EventHandler(this.sbtnsua_Click);
            this.btnxoa.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.btnxoa.Image = Properties.Resources.imgdelete;// (Image)manager.GetObject("btnxoa.Image");
            this.btnxoa.Location = new Point(0x10b, 0x1d9);
            this.btnxoa.Name = "btnxoa";
            this.btnxoa.Size = new Size(0x4b, 0x17);
            this.btnxoa.TabIndex = 10;
            this.btnxoa.Text = " &Hủy [F7]";
            this.btnxoa.Click += new EventHandler(this.btnxoa_Click);
            this.label8.BackColor = Color.ForestGreen;
            this.label8.Dock = DockStyle.Top;
            this.label8.Font = new Font("Tahoma", 16f);
            this.label8.ForeColor = Color.Yellow;
            this.label8.Location = new Point(0, 0);
            this.label8.Name = "label8";
            this.label8.Size = new Size(0x3a0, 0x30);
            this.label8.TabIndex = 11;
            this.label8.Text = "TH\x00d4NG TIN BỆNH NH\x00c2N";
            this.label8.TextAlign = ContentAlignment.MiddleCenter;
            this.gridds.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
            this.gridds.Location = new Point(0, 0x31);
            this.gridds.MainView = this.gridView1;
            this.gridds.Name = "gridds";
            this.gridds.RepositoryItems.AddRange(new RepositoryItem[] { this.repositoryItemTextEdit1 });
            this.gridds.Size = new Size(0x3a0, 0x126);
            this.gridds.TabIndex = 13;
            this.gridds.ViewCollection.AddRange(new BaseView[] { this.gridView1 });
            this.gridds.DoubleClick += new EventHandler(this.gridds_DoubleClick);
            this.gridds.KeyDown += new KeyEventHandler(this.ucbn_tiepdon_KeyDown);
            this.gridView1.Appearance.ColumnFilterButton.BackColor = Color.FromArgb(0xca, 0xdd, 0xd0);
            this.gridView1.Appearance.ColumnFilterButton.BorderColor = Color.FromArgb(0xca, 0xdd, 0xd0);
            this.gridView1.Appearance.ColumnFilterButton.ForeColor = Color.Black;
            this.gridView1.Appearance.ColumnFilterButton.Options.UseBackColor = true;
            this.gridView1.Appearance.ColumnFilterButton.Options.UseBorderColor = true;
            this.gridView1.Appearance.ColumnFilterButton.Options.UseForeColor = true;
            this.gridView1.Appearance.ColumnFilterButtonActive.BackColor = Color.FromArgb(0xd3, 0xe2, 0xd8);
            this.gridView1.Appearance.ColumnFilterButtonActive.BorderColor = Color.FromArgb(0xd3, 0xe2, 0xd8);
            this.gridView1.Appearance.ColumnFilterButtonActive.ForeColor = Color.Black;
            this.gridView1.Appearance.ColumnFilterButtonActive.Options.UseBackColor = true;
            this.gridView1.Appearance.ColumnFilterButtonActive.Options.UseBorderColor = true;
            this.gridView1.Appearance.ColumnFilterButtonActive.Options.UseForeColor = true;
            this.gridView1.Appearance.Empty.BackColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.Empty.BackColor2 = Color.White;
            this.gridView1.Appearance.Empty.Options.UseBackColor = true;
            this.gridView1.Appearance.EvenRow.BackColor = Color.FromArgb(0xdd, 0xe3, 0xf5);
            this.gridView1.Appearance.EvenRow.BorderColor = Color.FromArgb(0xdd, 0xe3, 0xf5);
            this.gridView1.Appearance.EvenRow.ForeColor = Color.Black;
            this.gridView1.Appearance.EvenRow.Options.UseBackColor = true;
            this.gridView1.Appearance.EvenRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.EvenRow.Options.UseForeColor = true;
            this.gridView1.Appearance.FilterCloseButton.BackColor = Color.FromArgb(0xca, 0xdd, 0xd0);
            this.gridView1.Appearance.FilterCloseButton.BorderColor = Color.FromArgb(0xca, 0xdd, 0xd0);
            this.gridView1.Appearance.FilterCloseButton.ForeColor = Color.Black;
            this.gridView1.Appearance.FilterCloseButton.Options.UseBackColor = true;
            this.gridView1.Appearance.FilterCloseButton.Options.UseBorderColor = true;
            this.gridView1.Appearance.FilterCloseButton.Options.UseForeColor = true;
            this.gridView1.Appearance.FilterPanel.BackColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.FilterPanel.BackColor2 = Color.White;
            this.gridView1.Appearance.FilterPanel.ForeColor = Color.Black;
            this.gridView1.Appearance.FilterPanel.Options.UseBackColor = true;
            this.gridView1.Appearance.FilterPanel.Options.UseForeColor = true;
            this.gridView1.Appearance.FixedLine.BackColor = Color.FromArgb(0x75, 0x88, 0x7a);
            this.gridView1.Appearance.FixedLine.Options.UseBackColor = true;
            this.gridView1.Appearance.FocusedCell.BackColor = Color.White;
            this.gridView1.Appearance.FocusedCell.ForeColor = Color.Black;
            this.gridView1.Appearance.FocusedCell.Options.UseBackColor = true;
            this.gridView1.Appearance.FocusedCell.Options.UseForeColor = true;
            this.gridView1.Appearance.FocusedRow.BackColor = Color.FromArgb(0x81, 0xab, 0xb1);
            this.gridView1.Appearance.FocusedRow.ForeColor = Color.White;
            this.gridView1.Appearance.FocusedRow.Options.UseBackColor = true;
            this.gridView1.Appearance.FocusedRow.Options.UseForeColor = true;
            this.gridView1.Appearance.FooterPanel.BackColor = Color.FromArgb(0xca, 0xdd, 0xd0);
            this.gridView1.Appearance.FooterPanel.BorderColor = Color.FromArgb(0xca, 0xdd, 0xd0);
            this.gridView1.Appearance.FooterPanel.ForeColor = Color.Black;
            this.gridView1.Appearance.FooterPanel.Options.UseBackColor = true;
            this.gridView1.Appearance.FooterPanel.Options.UseBorderColor = true;
            this.gridView1.Appearance.FooterPanel.Options.UseForeColor = true;
            this.gridView1.Appearance.GroupButton.BackColor = Color.FromArgb(0xb2, 0xd1, 0xbc);
            this.gridView1.Appearance.GroupButton.BorderColor = Color.FromArgb(0xb2, 0xd1, 0xbc);
            this.gridView1.Appearance.GroupButton.Options.UseBackColor = true;
            this.gridView1.Appearance.GroupButton.Options.UseBorderColor = true;
            this.gridView1.Appearance.GroupFooter.BackColor = Color.FromArgb(0xd7, 0xea, 0xdd);
            this.gridView1.Appearance.GroupFooter.BorderColor = Color.FromArgb(0xd7, 0xea, 0xdd);
            this.gridView1.Appearance.GroupFooter.ForeColor = Color.Black;
            this.gridView1.Appearance.GroupFooter.Options.UseBackColor = true;
            this.gridView1.Appearance.GroupFooter.Options.UseBorderColor = true;
            this.gridView1.Appearance.GroupFooter.Options.UseForeColor = true;
            this.gridView1.Appearance.GroupPanel.BackColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.GroupPanel.BackColor2 = Color.White;
            this.gridView1.Appearance.GroupPanel.ForeColor = Color.Black;
            this.gridView1.Appearance.GroupPanel.Options.UseBackColor = true;
            this.gridView1.Appearance.GroupPanel.Options.UseForeColor = true;
            this.gridView1.Appearance.GroupRow.BackColor = Color.FromArgb(0xd7, 0xea, 0xdd);
            this.gridView1.Appearance.GroupRow.BorderColor = Color.FromArgb(0xd7, 0xea, 0xdd);
            this.gridView1.Appearance.GroupRow.ForeColor = Color.Black;
            this.gridView1.Appearance.GroupRow.Options.UseBackColor = true;
            this.gridView1.Appearance.GroupRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.GroupRow.Options.UseForeColor = true;
            this.gridView1.Appearance.HeaderPanel.BackColor = Color.FromArgb(0xd3, 0xe2, 0xd8);
            this.gridView1.Appearance.HeaderPanel.BorderColor = Color.FromArgb(0xd3, 0xe2, 0xd8);
            this.gridView1.Appearance.HeaderPanel.ForeColor = Color.Black;
            this.gridView1.Appearance.HeaderPanel.Options.UseBackColor = true;
            this.gridView1.Appearance.HeaderPanel.Options.UseBorderColor = true;
            this.gridView1.Appearance.HeaderPanel.Options.UseForeColor = true;
            this.gridView1.Appearance.HideSelectionRow.BackColor = Color.FromArgb(0xba, 0xd3, 0xd7);
            this.gridView1.Appearance.HideSelectionRow.ForeColor = Color.FromArgb(0x68, 130, 0x86);
            this.gridView1.Appearance.HideSelectionRow.Options.UseBackColor = true;
            this.gridView1.Appearance.HideSelectionRow.Options.UseForeColor = true;
            this.gridView1.Appearance.HorzLine.BackColor = Color.FromArgb(0xac, 0xc5, 180);
            this.gridView1.Appearance.HorzLine.BorderColor = Color.FromArgb(0x75, 0x88, 0x7a);
            this.gridView1.Appearance.HorzLine.Options.UseBackColor = true;
            this.gridView1.Appearance.HorzLine.Options.UseBorderColor = true;
            this.gridView1.Appearance.OddRow.BackColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.OddRow.BorderColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.OddRow.ForeColor = Color.Black;
            this.gridView1.Appearance.OddRow.Options.UseBackColor = true;
            this.gridView1.Appearance.OddRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.OddRow.Options.UseForeColor = true;
            this.gridView1.Appearance.Preview.BackColor = Color.FromArgb(250, 250, 240);
            this.gridView1.Appearance.Preview.Font = new Font("Verdana", 7.5f);
            this.gridView1.Appearance.Preview.ForeColor = Color.FromArgb(0x68, 130, 0x86);
            this.gridView1.Appearance.Preview.Options.UseBackColor = true;
            this.gridView1.Appearance.Preview.Options.UseFont = true;
            this.gridView1.Appearance.Preview.Options.UseForeColor = true;
            this.gridView1.Appearance.Row.BackColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.Row.ForeColor = Color.Black;
            this.gridView1.Appearance.Row.Options.UseBackColor = true;
            this.gridView1.Appearance.Row.Options.UseForeColor = true;
            this.gridView1.Appearance.RowSeparator.BackColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.RowSeparator.BackColor2 = Color.White;
            this.gridView1.Appearance.RowSeparator.Options.UseBackColor = true;
            this.gridView1.Appearance.SelectedRow.BackColor = Color.FromArgb(0x9f, 0xc9, 0xcf);
            this.gridView1.Appearance.SelectedRow.ForeColor = Color.Black;
            this.gridView1.Appearance.SelectedRow.Options.UseBackColor = true;
            this.gridView1.Appearance.SelectedRow.Options.UseForeColor = true;
            this.gridView1.Appearance.TopNewRow.BackColor = Color.White;
            this.gridView1.Appearance.TopNewRow.Options.UseBackColor = true;
            this.gridView1.Appearance.VertLine.BackColor = Color.FromArgb(0xac, 0xc5, 180);
            this.gridView1.Appearance.VertLine.BorderColor = Color.FromArgb(0x75, 0x88, 0x7a);
            this.gridView1.Appearance.VertLine.Options.UseBackColor = true;
            this.gridView1.Appearance.VertLine.Options.UseBorderColor = true;
            this.gridView1.Columns.AddRange(new GridColumn[] { this.gridds_mabn, this.gridds_ten, this.gridds_idgioitinh, this.gridds_phai, this.gridds_namsinh, this.gridds_diachi, this.gridds_dienthoai, this.gridds_phuongxa, this.gridds_idphuongxa, this.gridds_ngaysinh });
            this.gridView1.GridControl = this.gridds;
            this.gridView1.Name = "gridView1";
            this.gridView1.OptionsView.AutoCalcPreviewLineCount = true;
            this.gridView1.OptionsView.EnableAppearanceEvenRow = true;
            this.gridView1.OptionsView.EnableAppearanceOddRow = true;
            this.gridView1.OptionsView.ShowAutoFilterRow = true;
            this.gridView1.OptionsView.ShowFooter = true;
            this.gridView1.OptionsView.ShowGroupPanel = false;
            this.gridView1.FocusedRowChanged += new FocusedRowChangedEventHandler(this.gridView1_FocusedRowChanged);
            this.gridds_mabn.Caption = "M\x00e3 số BN";
            this.gridds_mabn.FieldName = "mabn";
            this.gridds_mabn.Name = "gridds_mabn";
            this.gridds_mabn.OptionsColumn.AllowEdit = false;
            this.gridds_mabn.OptionsColumn.FixedWidth = true;
            this.gridds_mabn.OptionsColumn.ReadOnly = true;
            this.gridds_mabn.Summary.AddRange(new GridSummaryItem[] { new GridColumnSummaryItem(SummaryItemType.Count, "ma", "{0:n0}", 0) });
            this.gridds_mabn.Visible = true;
            this.gridds_mabn.VisibleIndex = 0;
            this.gridds_ten.Caption = "Họ v\x00e0 t\x00ean";
            this.gridds_ten.ColumnEdit = this.repositoryItemTextEdit1;
            this.gridds_ten.FieldName = "hoten";
            this.gridds_ten.Name = "gridds_ten";
            this.gridds_ten.OptionsColumn.AllowEdit = false;
            this.gridds_ten.OptionsColumn.FixedWidth = true;
            this.gridds_ten.OptionsColumn.ReadOnly = true;
            this.gridds_ten.Visible = true;
            this.gridds_ten.VisibleIndex = 1;
            this.gridds_ten.Width = 0xcb;
            this.repositoryItemTextEdit1.AutoHeight = false;
            this.repositoryItemTextEdit1.Name = "repositoryItemTextEdit1";
            this.repositoryItemTextEdit1.ReadOnly = true;
            this.gridds_idgioitinh.Caption = "idgioitinh";
            this.gridds_idgioitinh.FieldName = "idgioitinh";
            this.gridds_idgioitinh.Name = "gridds_idgioitinh";
            this.gridds_phai.Caption = "Giới t\x00ednh";
            this.gridds_phai.FieldName = "phai";
            this.gridds_phai.Name = "gridds_phai";
            this.gridds_phai.OptionsColumn.AllowEdit = false;
            this.gridds_phai.Visible = true;
            this.gridds_phai.VisibleIndex = 2;
            this.gridds_phai.Width = 0x38;
            this.gridds_namsinh.Caption = "Năm sinh";
            this.gridds_namsinh.FieldName = "namsinh";
            this.gridds_namsinh.Name = "gridds_namsinh";
            this.gridds_namsinh.OptionsColumn.AllowEdit = false;
            this.gridds_namsinh.Visible = true;
            this.gridds_namsinh.VisibleIndex = 3;
            this.gridds_namsinh.Width = 0x3d;
            this.gridds_diachi.Caption = "Địa chỉ";
            this.gridds_diachi.FieldName = "diachi";
            this.gridds_diachi.Name = "gridds_diachi";
            this.gridds_diachi.OptionsColumn.AllowEdit = false;
            this.gridds_diachi.Visible = true;
            this.gridds_diachi.VisibleIndex = 4;
            this.gridds_diachi.Width = 0xc5;
            this.gridds_dienthoai.Caption = "Điện thoại";
            this.gridds_dienthoai.FieldName = "dienthoai";
            this.gridds_dienthoai.Name = "gridds_dienthoai";
            this.gridds_dienthoai.OptionsColumn.AllowEdit = false;
            this.gridds_dienthoai.Visible = true;
            this.gridds_dienthoai.VisibleIndex = 5;
            this.gridds_dienthoai.Width = 0x54;
            this.gridds_phuongxa.Caption = "Phường x\x00e3";
            this.gridds_phuongxa.FieldName = "tenphuongxa";
            this.gridds_phuongxa.Name = "gridds_phuongxa";
            this.gridds_phuongxa.OptionsColumn.AllowEdit = false;
            this.gridds_phuongxa.Visible = true;
            this.gridds_phuongxa.VisibleIndex = 6;
            this.gridds_phuongxa.Width = 0xea;
            this.gridds_idphuongxa.Caption = "idphuongxa";
            this.gridds_idphuongxa.FieldName = "idphuongxa";
            this.gridds_idphuongxa.Name = "gridds_idphuongxa";
            this.gridds_ngaysinh.Caption = "ngaysinh";
            this.gridds_ngaysinh.FieldName = "ngaysinh";
            this.gridds_ngaysinh.Name = "gridds_ngaysinh";
            base.AutoScaleMode = AutoScaleMode.None;
            base.Controls.Add(this.gridds);
            base.Controls.Add(this.label8);
            base.Controls.Add(this.btnxoa);
            base.Controls.Add(this.groupControl1);
            base.Controls.Add(this.sbtnketthuc);
            base.Controls.Add(this.sbtnsua);
            base.Controls.Add(this.sbtnboqua);
            base.Controls.Add(this.sbtnluu);
            this.LookAndFeel.SkinName = "Blue";
            base.Name = "ucbn_thongtinbn";
            base.Size = new Size(0x3a0, 0x1f7);
            base.Load += new EventHandler(this.ucbn_tiepdon_Load);
            base.KeyDown += new KeyEventHandler(this.ucbn_tiepdon_KeyDown);
            this.txthoten.Properties.EndInit();
            this.txtdiachi.Properties.EndInit();
            this.txtdienthoai.Properties.EndInit();
            this.txtnamsinh.Properties.EndInit();
            this.groupControl1.EndInit();
            this.groupControl1.ResumeLayout(false);
            this.groupControl1.PerformLayout();
            this.txtmaphuongxa.Properties.EndInit();
            this.txttenphuongxa.Properties.EndInit();
            this.cbbgioitinh.Properties.EndInit();
            this.txtmabn2.Properties.EndInit();
            this.gridds.EndInit();
            this.gridView1.EndInit();
            this.repositoryItemTextEdit1.EndInit();
            base.ResumeLayout(false);
        }

        private void lkploaituoi_EditValueChanged(object sender, EventArgs e)
        {
            this.txttuoi_Validated(sender, e);
        }

        private void sbtnboqua_Click(object sender, EventArgs e)
        {
            this.f_loadcontrol_chophepsua(false);
        }

        private void sbtnluu_Click(object sender, EventArgs e)
        {
            if (this.f_kiemtra_luu())
            {
                dtoBNThongTinBN nbn = new dtoBNThongTinBN(this._xuli.pConFigData) {
                    DIACHI = this.txtdiachi.Text,
                    DIENTHOAI = this.txtdienthoai.Text,
                    HOTEN = this.txthoten.Text,
                    IDGIOITINH = Convert.ToInt16(this.cbbgioitinh.EditValue),
                    MABN = this.txtmabn2.Text,
                    NAMSINH = Convert.ToInt16(this.txtnamsinh.Text),
                    NGAYSINH = this.txtngaysinh.Text
                };
                try
                {
                    nbn.IDPHUONGXA = long.Parse(this.txtmaphuongxa.Tag.ToString());
                }
                catch
                {
                }
                if (!nbn.Update())
                {
                    MessageBox.Show("Kh\x00f4ng lưu được th\x00f4ng tin bệnh nh\x00e2n.", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
                else
                {
                    this.f_loaddata_dsbenhnhan();
                    this.f_loadinfo_dmsanpham(0);
                    this.f_loadcontrol_chophepsua(false);
                }
            }
        }

        private void sbtnsua_Click(object sender, EventArgs e)
        {
            if (!(this.txtmabn2.Text == ""))
            {
                this.f_loadcontrol_chophepsua(true);
            }
        }

        public virtual void stbnketthuc_Click(object sender, EventArgs e)
        {
            try
            {
                XtraTabPage parent = (XtraTabPage) base.Parent;
                XtraTabControl control = (XtraTabControl) parent.Parent;
                control.TabPages.Remove(parent);
            }
            catch
            {
                UserControl control2 = (UserControl) base.Parent;
                control2.Controls.Remove(this);
            }
        }

        private void stbntieptheo_Click(object sender, EventArgs e)
        {
            this.f_loadcontrol_benhnhan("", "", 0, "", "", "", "", 0L);
            base.ActiveControl = this.txtmabn2;
            this.f_loadcontrol_chophepsua(true);
        }

        private void txthoten_Enter(object sender, EventArgs e)
        {
        }

        private void txthoten_KeyDown(object sender, KeyEventArgs e)
        {
            this.ucbn_tiepdon_KeyDown(sender, e);
        }

        private void txthoten_TextChanged(object sender, EventArgs e)
        {
        }

        private void txtmabn2_Validated(object sender, EventArgs e)
        {
            if (this.txtmabn2.Text != "")
            {
                string str = "";
                string str2 = "";
                if (this.txtmabn2.Text.Length <= 4)
                {
                    str = this.txtmabn2.Text;
                }
                else
                {
                    str = this.txtmabn2.Text.Substring(0, 4);
                    str2 = this.txtmabn2.Text.Substring(4);
                }
                this.txtmabn2.Text = str.PadRight(4, '0') + str2.PadLeft(6, '0');
                string text = this.txtmabn2.Text;
                this.f_loadcontrol_benhnhan(text, "", 0, "", "", "", "", 0L);
                dtoBNThongTinBN nbn = new dtoBNThongTinBN(this._xuli.pConFigData) {
                    MABN = text
                };
                nbn.Load();
                if (nbn.HOTEN != "")
                {
                    this.f_loadcontrol_benhnhan(nbn.MABN, nbn.HOTEN, nbn.IDGIOITINH, nbn.NGAYSINH, nbn.NAMSINH.ToString(), nbn.DIACHI, nbn.DIENTHOAI, nbn.IDPHUONGXA);
                }
            }
        }

        private void txtmaphuongxa_Validated(object sender, EventArgs e)
        {
            this.f_setcontrol_phuongxa(this.txtmaphuongxa.Text, 0L);
        }

        private void txtnamsinh_Validated(object sender, EventArgs e)
        {
        }

        private void txtngaysinh_Validated(object sender, EventArgs e)
        {
            try
            {
                DateTime time = new BNTiepDon(this._xuli.pConFigData).f_tinh_ngaytuoi(this.txtngaysinh.Text, (this.txtnamsinh.Text == "") ? 0 : int.Parse(this.txtnamsinh.Text), 0, 0);
                this.txtnamsinh.Text = time.Year.ToString();
            }
            catch
            {
            }
        }

        private void txttuoi_Validated(object sender, EventArgs e)
        {
        }

        private void ucbn_tiepdon_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode != Keys.F2)
            {
                if (e.KeyCode == Keys.F3)
                {
                    if (this.sbtnsua.Enabled)
                    {
                        this.sbtnsua_Click(null, null);
                    }
                }
                else if (e.KeyCode == Keys.F5)
                {
                    if (this.sbtnluu.Enabled)
                    {
                        this.sbtnluu_Click(null, null);
                    }
                }
                else if (e.KeyCode == Keys.F4)
                {
                    if (this.sbtnboqua.Enabled)
                    {
                        this.sbtnboqua_Click(null, null);
                    }
                }
                else if (e.KeyCode == Keys.F7)
                {
                    if (this.btnxoa.Enabled)
                    {
                        this.btnxoa_Click(null, null);
                    }
                }
                else if (e.KeyCode == Keys.Enter)
                {
                    SendKeys.Send("{Tab}");
                }
                else if (e.KeyCode == Keys.F12)
                {
                    this.stbnketthuc_Click(null, null);
                }
            }
        }

        private void ucbn_tiepdon_Load(object sender, EventArgs e)
        {
            this.cbbgioitinh.Properties.DataSource = HangSo.GioiTinh.f_DanhSach();
            this.cbbgioitinh.Properties.DisplayMember = "ten";
            this.cbbgioitinh.Properties.ValueMember = "id";
            this.cbbgioitinh.ItemIndex = 0;
            this.f_loaddata_dsbenhnhan();
            this.sbtnboqua_Click(null, null);
            this.f_loadinfo_dmsanpham(0);
            base.ActiveControl = this.txtmabn2;
        }
    }
}

